// vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import path from 'path' // 1. 引入 'path' 模块

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  // 2. 添加 resolve 配置
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src') // 将 @ 指向 src 目录
    }
  },
  // 配置代理
  server: {
    proxy: {
      '/api': {
        target: 'http://your-backend-api-server.com', // 替换为你的后端服务器地址
        changeOrigin: true,
      }
    }
  }
})